package org.hot100_5.leetcode78;

import java.util.ArrayList;
import java.util.List;

public class Solution {

    //不含重复元素 子集问题

    List<List<Integer>> res = new ArrayList<>();
    List<Integer> item = new ArrayList<>();

    public List<List<Integer>> subsets(int[] nums) {
        backtracking(nums,0);
        return res;
    }

    private void backtracking(int []nums,int index){
        res.add(new ArrayList<>(item));

        if (index==nums.length){
            return;
        }

        for (int i = index; i < nums.length ; i++) {
            item.add(nums[i]);
            backtracking(nums,i+1);
            item.remove(item.size()-1);
        }
    }

}
